// Dialog.cpp: implementation of the CSIPDialogForMT class.
//
//////////////////////////////////////////////////////////////////////
#pragma warning(disable:4530)
#include "stdafx.h"
#include "SIPDialogForMT.h"
#include "SIPStack.h"
#include <assert.h>

#ifdef USE_DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

CSIPDialogForMT::CSIPDialogForMT(const CSIPNameAddr &contact)
	: CSIPDialog(contact)
// 	,m_RemoteTarget()
// 	,m_LocalUri()//CSIPHeader::To),
// 	,m_RemoteUri()//CSIPHeader::From),
// 	,m_sLocalTag("")
// 	,m_CallID()
// 	,m_nLocalSequence(0)
// 	,m_bLocalEmpty(true)
// 	,m_Contact(contact)
{

}

//2010-06-22 wangyu add MakeInitialInvite function with 3 parameters.
CSIPMessage* CSIPDialogForMT::MakeFrontEndPlayInitialInvite(const CSIPNameAddr& requestUri, const CSIPNameAddr& target,
                          const CSIPNameAddr& from)
{
	CSIPMessage* msg = CSIPStack::MakeRequest( target, from, m_Contact, INVITE);
	assert( msg );

	//m_Subscriber = target;
	//m_Registrar = registrar;
	msg->RequestLine().Uri() = *requestUri.GetUri();

	m_bLocalEmpty = false;
	m_nLocalSequence = msg->GetCSeq()->GetCSeq();
	m_CallID = *msg->GetCallId();
	if(msg->GetFrom()->GetValue("tag"))
		m_sLocalTag = msg->GetFrom()->GetValue("tag");  
	else
		m_sLocalTag = "";
	m_RemoteUri = *msg->GetTo()->GetNameAddr().GetUri();
	m_LocalUri = *msg->GetFrom()->GetNameAddr().GetUri();   
	m_RemoteTarget = *target.GetUri();   
	return msg;
}

// CSIPMessage* CSIPDialogForMT::MakeFrontEndPlayAck()//const CSIPMessage& original)
// {//RFC3261 13.2.2.4 2XX Responses Page82
// 	CSIPMessage* request = MakeRequest(ACK);
// 	request->CSeq() = m_pRequestMsg->CSeq();
// 	request->CSeq().SetMethod(ACK);
// 	
// 	request->To().SetNameAddr(m_RemoteUri);
// // 	if ( !m_sRemoteTag.empty() )
// // 	{
// // 		request->To().AddParam("tag",m_sRemoteTag.c_str());
// // 	}
// 	request->To().SetValue("tag", pvalue);
// 	
// 	return request;
// }

